<?php

namespace App\Services;

use App\Models\Slide;

class SlideService  extends BaseService
{
    /**
     * 获取换灯片列表
     * @return
     */
    public function listSlide($page,$limit,$sort,$order,$title,$isopen,$mobile) {
        $query = Slide::query();
        if(!empty($title)){
            $query->where('title','like',"%$title%");
        }
        if(isset($isopen)){
            $query->where('isopen',$isopen);
        }
        if(isset($mobile)){
            $query->where('mobile',$mobile);
        }

        return $query->orderBy($sort,$order)->paginate($limit, ['*'], 'page', $page);
    }
    /**
     * 获取换灯片
     * @return
     */
    public function listAll($sort,$order,$title,$isopen=1,$mobile=0) {
        $query = Slide::query();
        if(!empty($title)){
            $query->where('title','like',"%$title%");
        }
        if(isset($isopen)){
            $query->where('isopen',$isopen);
        }
        if(isset($mobile)){
            $query->where('mobile',$mobile);
        }
        return $query->orderBy($sort,$order)->get();
    }

}
